/*
 * @Author: NJ_1098 xiabaoxin
 * @Date: 2025-02-11 13:32:44
 * @LastEditors: NJ_1098 xiabaoxin
 * @LastEditTime: 2025-02-17 11:23:30
 * @Description: 用户路由
 */
const Router = require("koa-router");
const router = new Router({ prefix: "/user" });
const UserController = require("../controller/user.controller");
const UserMiddleware = require("../middleware/user.middleware");

/**
 * @author: NJ_1098 xiabaoxin
 * @description: 用户注册
 * @return {*}
 */
router.post(
  "/register",
  UserMiddleware.registerValidate,
  UserMiddleware.codeValidate,
  UserMiddleware.userExitValidate,
  UserController.register
);

/**
 * @author: NJ_1098 xiabaoxin
 * @description: 新增用户（微信）
 * @return {*}
 */
router.post(
  "/wxAdd",
  UserMiddleware.wxAddValidate,
  UserMiddleware.userExitValidate,
  UserController.wxAdd
);

/**
 * @author: NJ_1098 xiabaoxin
 * @description: 删除用户
 * @return {*}
 */
router.post(
  "/delete",
  UserMiddleware.verifyToken,
  UserMiddleware.deleteValidate,
  UserController.delete
);

/**
 * @author: NJ_1098 xiabaoxin
 * @description: 登录
 * @return {*}
 */
router.post("/wxLogin", UserMiddleware.wxLoginValidate, UserController.wxLogin);

/**
 * @author: NJ_1098 xiabaoxin
 * @description: 获取微信小程序openid
 * @return {*}
 */
router.get("/getOpenid", UserController.getOpenid);

/**
 * @author: NJ_1098 xiabaoxin
 * @description: 获取用户信息
 * @return {*}
 */
router.get("/getInfo", UserMiddleware.verifyToken, UserController.getInfo);

/**
 * @author: NJ_1098 xiabaoxin
 * @description: 更新用户信息
 * @return {*}
 */
router.post(
  "/update",
  UserMiddleware.verifyToken,
  UserMiddleware.updateValidate,
  UserController.update
);

module.exports = router;
